Morris' tree traversal algorithm reconsidered

نویسندگان

  • Prabhaker Mateti
  • Ravi Manghirmalani
چکیده

In 1968, Knuth posed the problem of designing a stack-free, tag-free, non-recursive algorithm that traversed the tree in in-order while leaving it unaltered in the end. Since then, numerous solutions have appeared in the literature. The 1979 algorithm by Morris is one of the most elegant of these solutions. The algorithm is clearly non-recursive, and appears, at first glance, to use neither a stack, nor tag fields. We present an insightful derivation of this algorithm. We also show that a stack is indeed present and ‘time-shares’ the right-link fields of the tree nodes. Our proof comes in two parts: (a) We start with a traversal algorithm that explicitly uses a stack, and show that it is computationally equivalent to another that uses a non-standard implementation of a stack; (b) We then show that the later algorithm can be transformed to Morris’ algorithm using only control-structure transformations. ∗This work was partially supported by NSF MCS83-03140.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals

It is well-known that, given inorder traversal along with one of the preorder or postorder traversals of a binary tree, the tree can be determined uniquely. Several algorithms have been proposed to reconstruct a binary tree from its inorder and preorder traversals. There is one study to reconstruct a binary tree from its inorder and postorder traversals, and this algorithm takes running time of...

متن کامل

An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals

It is well-known that, given inorder traversal along with one of the preorder or postorder traversals of a binary tree, the tree can be determined uniquely. Several algorithms have been proposed to reconstruct a binary tree from its inorder and preorder traversals. There is one study to reconstruct a binary tree from its inorder and postorder traversals, and this algorithm takes running time of...

متن کامل

A novel algorithm to determine the leaf (leaves) of a binary tree from its preorder and postorder traversals

Binary trees are essential structures in Computer Science. The leaf (leaves) of a binary tree is one of the most significant aspects of it. In this study, we prove that the order of a leaf (leaves) of a binary tree is the same in the main tree traversals; preorder, inorder, and postorder. Then, we prove that given the preorder and postorder traversals of a binary tree, the leaf (leaves) of a bi...

متن کامل

Fast nGram-Based String Search Over Data Encoded Using Algebraic Signatures

We propose a novel string search algorithm for data stored once and read many times. Our search method combines the sublinear traversal of the record (as in Boyer Moore or Knuth-Morris-Pratt) with the agglomeration of parts of the record and search pattern into a single character – the algebraic signature – in the manner of Karp-Rabin. Our experiments show that our algorithm is up to seventy ti...

متن کامل

Stackless Ray Traversal for kD-Trees with Sparse Boxes

We present a new stackless ray traversal algorithm which makes use of kD-tree augmented with sparsely distributed bounding boxes. The proposed traversal algorithm is not restricted to start the hierarchy traversal at the root node and so it can exploit the knowledge of the ray origin. The algorithm achieves traversal times comparable with the traditional hierarchical traversal as well as recent...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Sci. Comput. Program.

دوره 11  شماره 

صفحات  -

تاریخ انتشار 1988